$(document).ready(function () {
	var pageTag = $("[name='pageTag']").val();
    $(".nav-item").removeClass("active");
    $("#" + pageTag).addClass("active");

    fetchBorrowedHistory();
	fetchAllBorrowedRankingList();
});

function fetchBorrowedHistory() {
    $('#borrowed-history').bootstrapTable({
        method: 'get', 
        dataType: "json", 
        pageSize: 20,  
        pageNumber: 1, 
        toolbar: "#toolbar",
        sortName: "XID",
        sortOrder: "asc",
        clickToSelect: "true",
        sidePagination: "server",
        queryParamsType: "",
        queryParams: getBorrowedHistoryParams,  
        pagination: "true",
        pageList: "[20, All]",
        search: "true",
        url: "../Handle/BorrowHandlerService.ashx?method=Get_Family_Borrow_Book_List",
        onClickRow: function (row) {  
            window.open("Book.aspx?BID="+row["bid"]); 
        }, 
        responseHandler: function (res) {
            res.total = res.RecordCount;
            //console.log(res);
            return res;
        },
    });
}

function fetchAllBorrowedRankingList() {
    $('#borrowed-ranking-list').bootstrapTable({
        //toggle: "table",
        method: 'get', 
        dataType: "json", 
        pageSize: 20,  
        pageNumber: 1, 
        //toolbar: "#toolbar",
        //sortName: "XID",
        //sortOrder: "desc",
        //clickToSelect: "true",
        sidePagination: "server",
        queryParamsType: "",
        queryParams: getBorrowedRankingParams, 
        // pageList: "[20, All]",
        url: "../Handle/OtherHandlerService.ashx?method=Ad_Report_Get_Summary_List",
        responseHandler: function (res) {
            // console.log(res);
            return res;
        },
    });
}

function getBorrowedHistoryParams(params) {
    var temp = { 
        PageSize : params.pageSize, 
        PageIndex : params.pageNumber,
        ProcedureID : 3
    };
    return temp;
}

function getBorrowedRankingParams(params) {
    var temp = { 
        ProcedureID : 9
    };
    return temp;
}